API 系の情報はwww.figma.com/developers/docsにまとまっています。
API のオリジンはapi.figma.com
で、各 API ではヘッダーにX-Figma-Token: *****-********-****-****-****-************
を置いて認証を通る必要があります。
コメントを取得してみる
ある Figma のドキュメントにはこんなコメントがされている状態だとします。
さて、コメントを取得するための API はhttps://api.figma.com/v1/files/:key/comments
となっています。ドキュメントをシェアする時、 https://www.figma.com/file/************************/title
という URL だと思いますが、この************************
が:key
に入ります。
では叩いてみます。
Bash
curl -s \
-H 'X-Figma-Token: *****-********-****-****-****-************' \
https://api.figma.com/v1/files/************************/comments
こんな感じでコメントが取得できました。
Json
{
"comments": [
{
"id": "*******",
"file_key": "************************",
"parent_id": "",
"user": {
"handle": "nju33",
"img_url": "https://www.gravatar.com/avatar/...",
"id": "******************"
},
"created_at": "2019-04-20T16:48:31Z",
"resolved_at": null,
"message": "コメントテスト:grinning:",
"client_meta": {
"node_id": "0:1",
"node_offset": {
"x": 640,
"y": -527
}
},
"order_id": "1"
}
]
}